<script type="text/javascript" src="/static/js/jquery.ajaxfileupload.js"></script>

<script>
	$(function(){
		$('#{{datagrid_id}}').datagrid({
		    columns:[[
		            {field:'accountid',title:'交易账户',width:120},
		            {field:'name',title:'名称',width:39},
		            {field:'identify',title:'身份证号',width:120},
		            
		            {field:'tradeTime',title:'交易时间',width:80},
		            {field:'tradeAmount',title:'交易金额',width:39},
                    {field:'tradeType',title:'交易类型',width:80},
                    {field:'status',title:'交易状态',width:86},
                    {field:'id',title:'操作选项',width:78,
                      formatter:function(value,row,index){
                
				         return '<a onclick="javascript:return agree('+value+');" href="#">同意充值</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="javascript:return refuse('+value+')" href="#">拒绝充值</a>';
			            }
			
		            }
	                ]],
	          toolbar:[{
		                id:'',
		                text:'公司充值',
		                iconCls:'icon-add',
		                handler:function(){
			                $.jBox("get:/lottery/accounts/myself_recharge",{
                            title: '公司充值',
                            width:840,
                            height: 500,
                            top: '9%',
                            buttons: {},
                            loaded:function(){
 	            	

 	            }
           });
		}},'-',
		{
			id:'btnimport',
			text:'导入充值',
			iconCls:'icon-ok',
			handler: import_record
		}
	],

		    onLoadError: function() {
		    	$.jBox.tip('没有数据或根据搜索条件查不到相关数据', 'info');
		    	$("div.datagrid-body").css("height",0).find("table > tbody").empty();
		    	$("div.datagrid-view").css("height",'23px');
		    }
		});
		 $('#{{datagrid_id}}s').searchbox({

            width:300,  
            searcher:function(value,name){
            	var result = $('#{{datagrid_id}}').datagrid('reload', {
        			query_key: name,
        			query_value: value
        		});
            },
            menu:'#{{datagrid_id}}mm',  
            prompt:'请输入搜索条件'  
        });
	});
	function agree(value){		
		var message = '确定要该账户充值吗？<br/>' ;
        $.jBox.confirm(message, "提示", function (v, h, f) {
            if (v == 'ok'){
            	$.ajax({
                    type:'POST',
                    url:'/lottery/accounts/agree_recharge',
                    data: {id:value},
                    success:function(data,status){
                    	$.jBox.tip('交易成功', 'success');
                    	$('#{{datagrid_id}}').datagrid('reload');
                    },
                    error:function (req, status, error){
                    	$.jBox.tip('交易失败', 'error');
                    }
                });
            }
            return true;
        });
       	return false;
	}	
	
function refuse(value){		
		var message = '确定要拒绝该账户充值吗？<br/>' ;
        $.jBox.confirm(message, "提示", function (v, h, f) {
            if (v == 'ok'){
			   $.jBox("get:/lottery/accounts/refuse_recharge/"+value,{
                   title: '拒绝理由',
                   width: 550,
                   height: 350,
                   top: '9%',
                   buttons: {},
                   loaded:function(){
 	              }
                });
            }
            return true;      
        });
       	return false;
	}
	
function upload(){

	$.ajaxFileUpload
		(
			{
				url:'/lottery/account/handle_bank_report',
				secureuri:false,
				fileElementId:'bankreportfile_id',
				dataType: 'json',
				success: function (data, status) {
					$('#{{datagrid_id}}').datagrid('reload', {})
					$.jBox.tip(data.message, 'success');
					$("#bank_report_uploadWin").window("close");
				},
				error: function (data, status, e) {
					if(data.message != '' && data.message !=undefined){
						$.jBox.tip('导入失败:'+data.message, 'error');
					}else{
						$.jBox.tip('导入失败,请刷新页面后重新导入.', 'error');
					}
				},
				complete: function(req, status) {
					
				}
			}
		)
		return true;
}

function cancelupload(){
	$("#bank_report_uploadWin").window("close");
}

function import_record(){
	 $('#bank_report_uploadWin').window({
	 title : '充值报表导入',  
		height : 105,  
		width : 400
	});
	$("#bankreportfile_id").val('')
	$("#bank_report_uploadWin").window("open");  
}
</script>

<form id="upForm" method="POST" enctype="multipart/form-data">   
    <div id="bank_report_uploadWin" class="easyui-window" title="充值报表上传" modal="true" closed="true" style="padding:5px;">  
	  	上传文件：<input type="file" name="reportfile" id="bankreportfile_id" style="width:80%" />    
	  	<br/>
	  	<div align="center" style="margin-top:5px;">
		  	<input type="submit" value="提交" onclick="return upload();"/>   
		  	<input type="button" value="取消" onclick="return cancelupload();" />
	  	</div>   
	 </div>
</form>
	    
<div style="padding:20px;overflow:hidden;" class="ajust_height">
<div style="padding-bottom:20px;overflow:hidden;">
		<input id="{{datagrid_id}}s"></input>
		<div id="{{datagrid_id}}mm" style="width:120px">
			<div name="account" iconCls="icon-ok">额度账号</div>
			<div name="name" iconCls="icon-ok">姓名</div>
		</div>
	</div>
	
	<table id="{{datagrid_id}}"  striped="true" url="/lottery/accounts/company_re"
		pagination="true" iconCls="icon-save" url="" fitColumns="true" singleSelect="false"
		rownumbers="true" pageSize="15"   pageList=" [5,10,15,20,25]">
	</table>
</div>












 



	

